package TAIC.util;

import java.io.File;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class GetSVMFromCaltech {
	static public void main ( String args [] ) throws Exception {
		if ( args.length != 2 ) {
			System.out.println ( "please input the svmFile and configFile" );
			return ;
		}
		( new GetSVMFromCaltech ()).work( args) ; 
	}
	
	public void work (String [] args ) throws Exception {
		HashMap < Integer, Integer > list = new HashMap < Integer, Integer >() ;  
		HashMap < Integer, String > name = new HashMap < Integer, String >() ;  
		Scanner scanner = new Scanner ( new File ( args [ 1 ] )) ;
		int index = 0 ; 
		while ( scanner.hasNextLine() ) {			
			String str = scanner.nextLine() ;
			int pos = str.indexOf( ".") ;
			list.put(Integer.valueOf(str.substring(0,pos)) - 1, index ++ );
			name.put ( Integer.valueOf(str.substring(0,pos)) - 1 , str.substring(pos+1) ) ;
		}
		
		scanner.close() ;
		scanner = new Scanner ( new File ( args[ 0 ] ) ); 
		PrintStream fout = new PrintStream ( new File ( "data.txt" )) ; 
		int row = scanner.nextInt() ;
		scanner.nextInt () ;
		for ( int i = 0 ; i < row ; i ++ ) {
			Integer classNo = list.get(  scanner.nextInt())  ;
			scanner.nextInt(); 
			String str = scanner.nextLine() ;
			if ( classNo == null ) continue ;
			fout.println ( classNo + " " + str ) ;
		}
		fout.close() ;
		
		fout = new PrintStream ( new File ( "className.txt" )) ; 
		for ( Map.Entry < Integer , String > e : name.entrySet() ) 
			fout.println ( list.get(e.getKey()) + " " + e.getValue() ) ;
		fout.close() ;
	}
	
}
